<template>
  <view>
    <view class="uni-container">
      <u-button icon="reload" text="刷新"
                style="width: 120rpx;height: 68rpx; border-radius: 68rpx; margin-left: 10rpx;"
                @click="presa"></u-button>
      <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
        <uni-tr>
          <uni-th width="50" align="center">操作时间</uni-th>
          <uni-th width="auto" align="center">操作信息</uni-th>
          <uni-th width="80" align="center">类型</uni-th>
        </uni-tr>
        <uni-tr v-for="(item, index) in tableData" :key="index">
          <uni-td align="center" style="font-weight: bold">{{ item.creatTime }}</uni-td>
          <uni-td align="center" style="font-weight: bold">{{ item.infor }}</uni-td>
          <uni-td align="center" style="font-weight: bold">{{ item.type }}</uni-td>
        </uni-tr>
      </uni-table>

      <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent"
                                                       :total="total" @change="change" /></view>
    </view>
  </view>
</template>


<script>
import {queryczrz} from "../../common/api";
export default {
  data() {
    return {
      tableData: [],
      // 每页数据量
      pageSize: 10,
      // 当前页
      pageCurrent: 1,
      // 数据总量
      total: 0,
      loading: false
    }
  },
  onLoad(i) {
    this.getData();
  },
  methods: {
    presa(){
      this.getData()
    },
    getData() {
      let from = {}
      from.companyId = uni.getStorageSync('companyId');
      uni.showLoading({
        title: '加载中...',
      });
      queryczrz(from).then((res) => {
        uni.hideLoading();
        // this.tableData = res.data
        this.tableData = res.data.sort((a, b) => {
          const dateA = new Date(a.creatTime);
          const dateB = new Date(b.creatTime);
          return dateB - dateA;
        });
      })
    }
  },
}
</script>


<style>
</style>
